package com.xuelang.pipeline.entry.pipeline;

import com.xuelang.pipeline.app.pipeline.ChangeMgmtService;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.pipeline.IChangeMgmtService;
import com.xuelang.pipeline.client.pipeline.dto.ChangeMgmtDTO;
import com.xuelang.pipeline.client.pipeline.dto.ChangeMgmtQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 组件变更管理控制类
 *
 * @author : yixin.lys
 * @date : 2024-08-02 14:49
 **/
@Slf4j
@RestController
@RequestMapping("/changeMgmt")
public class ChangeMgmtController implements IChangeMgmtService {

    @Autowired
    private ChangeMgmtService changeMgmtService;

    @Override
    public ApiResult<PageRecord<ChangeMgmtDTO>> page(PageParam<ChangeMgmtQuery> query) {
        return ApiResult.success(changeMgmtService.page(query));
    }

    @Override
    public ApiResult<Boolean> add(ChangeMgmtDTO toAdd) {
        return ApiResult.success(changeMgmtService.add(toAdd));
    }

    @Override
    public ApiResult<Boolean> update(ChangeMgmtDTO toUpdate) {
        return ApiResult.success(changeMgmtService.update(toUpdate));
    }

    @Override
    public ApiResult<ChangeMgmtDTO> queryById(String id) {
        return ApiResult.success(changeMgmtService.queryById(id));
    }

    @Override
    public ApiResult<Boolean> removeById(String id) {
        return ApiResult.success(changeMgmtService.removeById(id));
    }

    @Override
    public ApiResult<Boolean> removeByComponentLabel(String componentLabel) {
        return ApiResult.success(changeMgmtService.removeByComponentLabel(componentLabel));
    }
}
